package com.fizy.client.enums;

import java.util.HashMap;
import java.util.Map;

public enum Operation {
	PASSED("1", "Passed"), MOODS("1", "/v1/moods"), MOODS_ID("2", "/v1/moods/{MOOD_ID}"), TRACKS("3", "/v1/tracks"), TRACKS_ID("3", "/v1/tracks/"), ALBUM("3", "/v1/albums"), ALBUM_ID("3",
			"/v1/albums/"), ALBUM_ID_TRACKS("3", "/v1/albums/"), ARTIST("3", "/v1/artists"), ARTIST_ID("3", "/v1/artists/"), ARTIST_ID_TOP_TRACKS("3",
			"/v1/artists/{ARTIST_ID}/top_tracks"), ARTIST_ID_ALBUM("3", "/v1/artists/"), SEARCH("3", "/v1/search?query="), SEARCH_RESOURCE("3", "/v1/search/{RESOURCE}");
	
	private String name;
	private String urlPattern;

	/**
	 * A mapping between the integer code and its corresponding Status to facilitate lookup by code.
	 */
	private static Map<String, Operation> nameToMethodsMapping;

	private Operation(String name, String urlPattern) {
		this.name = name;
		this.urlPattern = urlPattern;
	}

	public static Operation getStatus(String name) {
		if (nameToMethodsMapping == null) {
			initMapping();
		}
		return nameToMethodsMapping.get(name);
	}

	private static void initMapping() {
		nameToMethodsMapping = new HashMap<String, Operation>();
		for (Operation s : values()) {
			nameToMethodsMapping.put(s.name, s);
		}
	}

	public String getName() {
		return name;
	}

	public String getUrlPattern() {
		return urlPattern;
	}

	public static Map<String, Operation> getNameToMethodsMapping() {
		return nameToMethodsMapping;
	}

}
